package com.journey.org.ui.video.recommend

import android.os.Bundle
import com.journey.org.entity.ItemXRecommend
import com.journey.org.ui.video.broadcast.BroadcastActivity
import com.mvvmhabit.org.base.MultiItemViewModel
import com.mvvmhabit.org.binding.command.BindingAction
import com.mvvmhabit.org.binding.command.BindingCommand
import com.mvvmhabit.org.utils.loadTimeByLong

/**
 * @Date: 2020/11/19 16:46
 * @Author:小妖
 * @Description: 推荐视频 - 标题
 */
class RecommendDailyViewModel(vm: RecommendViewModel, val entity: ItemXRecommend) :
    MultiItemViewModel<RecommendViewModel>(vm) {

    val showTime = loadTimeByLong(entity.data.content.data.duration.toLong())

    val onEnterVideoCommand = BindingCommand<Any>(object : BindingAction {
        override fun call() {
            val bundle = Bundle()
            bundle.putString("url", entity.data.content.data.playUrl)
            bundle.putString("id", entity.data.content.data.id.toString())
            bundle.putString("type", "recommend")
            bundle.putString("time", entity.data.content.data.releaseTime.toString())
            bundle.putString("title", entity.data.content.data.title)
            bundle.putString("dec", entity.data.content.data.description)
            bundle.putString(
                "content",
                "# " + entity.data.content.data.category + " / " + entity.data.content.data.author.name
            )
            viewModel.startActivity(BroadcastActivity::class.java, bundle)
        }
    })

}